package com.demo.app2.model.user;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.demo.app2.RoleInfo;
import com.sun.javafx.collections.MappingChange.Map;

@Controller
@RequestMapping("/user")
public class UserController {
	public static Map<String, RoleInfo> map=new HashMap<String, RoleInfo>();
	@RequestMapping("/dea")
	public String userInfo(Model model) {
		List<UserInfo> list = new ArrayList<UserInfo>();
		UserInfo user=new UserInfo();
		user.setUsername("dz");
		user.setUserage("18");
		user.setUsersex("男");
		UserInfo user1=new UserInfo();
		user1.setUsername("dz");
		user1.setUserage("18");
		user1.setUsersex("男");
		UserInfo user2=new UserInfo();
		user2.setUsername("dz");
		user2.setUserage("18");
		user2.setUsersex("男");
		UserInfo user3=new UserInfo();
		user3.setUsername("dz");
		user3.setUserage("18");
		user3.setUsersex("男");
		list.add(user);
		list.add(user1);
		list.add(user2);
		list.add(user3);
		model.addAttribute("users", list);
		return "user/user" ;
	}
	
	@RequestMapping("/adduser")
	public String adduser(HttpServletRequest request,Model model) {
		String id=request.getParameter("id");
		if("".equals(id)||null==id) {
			return "/user/admin-add";
		}
		else {
			RoleInfo role =map.get(id);
			model.addAttribute("role",role);
			return "/user/admin-add";
		}
	}
	

}
